#include "routewidget.h"
#include "ui_routewidget.h"
#include <QDebug>
routeWidget::routeWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::routeWidget)
{
    ui->setupUi(this);
    query = new OtherQueryWidget();
    viewMap = new QWebView(ui->view_map_widget);
    QVBoxLayout* lay = new QVBoxLayout;
    lay->addWidget(viewMap);
    ui->view_map_widget->setLayout(lay);

    //this->loadRoute()
    viewMap->load(QUrl("qrc:/urls/Qmap.html"));
    viewMap->show();

}

routeWidget::~routeWidget()
{
    delete ui;
}

void routeWidget::on_back_btn_3_clicked()
{
    //this->savaRoute()
    this->close();

}

void routeWidget::on_RouteBtn_clicked()

{   QString http("https://api.map.baidu.com/direction?origin=source&destination=target&mode=driving&region=西安&output=html&src=webapp.baidu.openAPIdemo");

    //这里会有一个路线弹窗和浏览器弹窗
    QString src = ui->sourceEdit->text();
    QString trg = ui->targetEdit->text();
    http.replace(tr("source"),src);
    http.replace(tr("target"),trg);
    QDesktopServices::openUrl(QUrl(http));

    //qDebug()<<http;
    qDebug()<<http;
    //this->viewMap->load(QUrl(http));
    //viewMap->close();
    viewMap->show();

}

void routeWidget::on_other_query_btn_clicked()
{
    query->show();
}
